// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** listAttendanceInfo GET /daily/attendanceInfo */
export async function listAttendanceInfoUsingGET(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.listAttendanceInfoUsingGETParams,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponsePageInfoAttendanceInfoDTO_>('/daily/attendanceInfo', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** editAttendanceInfo PUT /daily/attendanceInfo */
export async function editAttendanceInfoUsingPUT(
  body: API.EditAttendanceInfoQuery,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponseBoolean_>('/daily/attendanceInfo', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** addAttendanceInfo POST /daily/attendanceInfo */
export async function addAttendanceInfoUsingPOST(
  body: API.AddAttendanceInfoQuery,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponseBoolean_>('/daily/attendanceInfo', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** deleteAttendanceInfo DELETE /daily/attendanceInfo */
export async function deleteAttendanceInfoUsingDELETE(
  body: API.DeleteAttendanceInfoQuery,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponseBoolean_>('/daily/attendanceInfo', {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** downloadAttendanceData GET /daily/attendanceInfo/download */
export async function downloadAttendanceDataUsingGET(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.downloadAttendanceDataUsingGETParams,
  options?: { [key: string]: any },
) {
  return request<any>('/daily/attendanceInfo/download', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** upload POST /daily/attendanceInfo/upload */
export async function uploadUsingPOST(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.uploadUsingPOSTParams,
  body: string,
  options?: { [key: string]: any },
) {
  const formData = new FormData();

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele];

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''));
        } else {
          formData.append(ele, JSON.stringify(item));
        }
      } else {
        formData.append(ele, item);
      }
    }
  });

  return request<API.BaseResponseString_>('/daily/attendanceInfo/upload', {
    method: 'POST',
    params: {
      ...params,
    },
    data: formData,
    requestType: 'form',
    ...(options || {}),
  });
}
